package com.my.goodsmanage.controller;

import com.my.goodsmanage.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @author 徐佳辉
 * @date 2020/8/3 9:04
 */
@Controller
@Slf4j
public class ViewController {


    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public String login() {
        return "login";
    }
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String login2() {
        return "login";
    }

    @RequestMapping(value = "/info")
    public String info(HttpSession session) {
        System.out.println("info");
        User user = (User) session.getAttribute("user");
        if (user == null) {
            return "redirect:login";
        } else {
            return "info";
        }
    }
    @RequestMapping(value = "/eve")
    public String eve(HttpSession session) {
        System.out.println("eve");
        User user = (User) session.getAttribute("user");
        if (user == null) {
            return "redirect:login";
        } else {
            return "eve";
        }
    }

    @RequestMapping("/register")
    public String register() {
        return "register";
    }

    @RequestMapping("/insert")
    public String insert() {
        return "insert";
    }
    @RequestMapping("/insertthing")
    public String insertthing() {
        return "insertthing";
    }
    @RequestMapping("/up")
    public String test(HttpSession session) {
        User user = (User) session.getAttribute("user");
        if (user == null) {
            return "redirect:login";
        } else {

            return "up";
        }
    }

    @RequestMapping("/changepwd")
    public String change() {
        return "change";
    }


    @RequestMapping("/thing")
    public String thing(HttpSession session) {
        User user = (User) session.getAttribute("user");
        if (user == null) {
            return "redirect:login";
        } else {
            return "thing";
        }

    }

    /**
     * 密码管理页面
     * @param session
     * @return
     */
    @RequestMapping("/password")
    public String password(HttpSession session) {
        User user = (User) session.getAttribute("user");
        if (user == null) {
            return "redirect:login";
        } else {
            return "passwordmanage";
        }

    }


}
